var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function o() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  ActivityHomePageView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.tempArray = []),
        WebSocketService.addListener({
          caller: e,
          code: 5321,
          method: e.onLoadHuoDongActData,
        }),
        e.btn_close_act_homepage.on(
          Laya.Event.CLICK,
          e,
          e.onClickClosePageAction
        ),
        (e.list_activity_homepage.vScrollBarSkin = ""),
        (e.list_activity_homepage.selectEnable = !0),
        e.list_activity_homepage.on(
          Laya.Event.CLICK,
          e,
          e.onSelectItemHomePageAction
        ),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showActHomePageView = function () {
        return (
          null == this.actHomePageV && (this.actHomePageV = new e()),
          this.actHomePageV.initData(),
          this.actHomePageV
        );
      }),
      (e.prototype.initData = function () {
        (this.activityArrs = []),
          (this.worldcupArr = []),
          (this.newComArr = []),
          WebSocketService.send({ c: 5321, d: { roleId: Global.roleId } }),
          this.refreshListData();
      }),
      (e.prototype.onLoadHuoDongActData = function (t) {
        var e = t.data;
        if (((this.tempArray = []), e && e.length > 0)) {
          for (var i = 0; i < e.length; i++) {
            var o = e[i];
            this.isbetweenTime(o.start, o.end) && this.newComArr.push(o);
          }
          this.refreshListData();
        }
      }),
      (e.prototype.refreshListData = function () {
        if (((this.activityArrs = []), this.tempArray.length > 0)) {
          this.list_activity_homepage.visible = !0;
          for (var t = void 0, e = 0; e < this.tempArray.length; e++) {
            (t = {
              id: (i = this.tempArray[e]).id,
              item0: { text: i.item0 },
              item1: { text: i.item1 },
            }),
              this.activityArrs.push(t);
          }
        }
        if (this.worldcupArr.length > 0) {
          this.list_activity_homepage.visible = !0;
          for (var t = void 0, e = 0; e < this.worldcupArr.length; e++) {
            (t = {
              id: (i = this.worldcupArr[e]).id,
              item0: { text: i.item0 },
              item1: { text: i.item1 },
            }),
              this.activityArrs.push(t);
          }
        }
        if (this.newComArr.length > 0) {
          this.list_activity_homepage.visible = !0;
          for (var t = void 0, e = 0; e < this.newComArr.length; e++) {
            var i = this.newComArr[e];
            (t = {
              id: i.id,
              item0: { text: i.name },
              item1: { text: i.start + " 到 " + i.end },
              name: i.name,
              start: i.start,
              end: i.end,
            }),
              this.activityArrs.push(t);
          }
        }
        this.list_activity_homepage.dataSource = this.activityArrs;
      }),
      (e.prototype.onSelectItemHomePageAction = function (t) {
        if ("" != t.target.name) {
          var e = this.list_activity_homepage.selectedItem,
            i = this.activityArrs[this.list_activity_homepage.selectedIndex];
          if (i)
            if (1 == i.id) {
              var o = WorldCupPageView.openWorldCupView();
              (o.y = 35), Laya.stage.addChild(o);
            } else if (2 == i.id) {
              var a = DaBiPingView.openDaBiPing();
              (a.y = 35), Laya.stage.addChild(a);
            } else if (417 == i.id)
              CommonUIDialog.showCommonUIDialog(e, "lihe");
            else {
              if (418 != i.id) return;
              var r = SlotmachineView.openSlotView();
              (r.y = 35), Laya.stage.addChild(r);
            }
          this.onClickClosePageAction();
        }
      }),
      (e.prototype.is24HourContain = function (t) {
        var e = !0;
        if (t < 0) {
          86400 + t < 0 && (e = !1);
        }
        return e;
      }),
      (e.prototype.isbetweenTime = function (t, e) {
        var i = new Date(t),
          o = new Date(e + " 23:59:00"),
          a = new Date();
        return (a >= i && a <= o) || (console.log("处于时间之外"), !1);
      }),
      (e.prototype.isTimeRangeContain = function (t, e) {
        var i,
          o = new Date(),
          a = ""
            .concat(o.getFullYear(), "-")
            .concat(o.getMonth() + 1, "-")
            .concat(o.getDate(), " "),
          r = new Date(a + t).getTime(),
          n = new Date(a + e).getTime(),
          s = o.getTime(),
          c = r > n;
        return (
          c && ((i = [n, r]), (r = i[0]), (n = i[1])), s > r && s < n ? !c : !!c
        );
      }),
      (e.prototype.onClickClosePageAction = function () {
        this.removeSelf();
      }),
      e
    );
  })(ui.ActivityController.ActivityHomePageViewUI);
